package com.like.hospitalworld;

import android.os.Bundle;

import com.like.fragment.OfflineDeleteFragment;
import com.like.fragment.OfflineEditFragment;

import org.xutils.view.annotation.ContentView;

/**
 * Created by MGC13 on 2016/5/31.
 */
@ContentView(R.layout.activity_offline_download)
public class OfflineDownloadActivity extends BaseActivity implements OfflineDeleteFragment.OnDoneClickListener,
        OfflineEditFragment.OnEditClickListener {

    private OfflineEditFragment editFragment;
    private OfflineDeleteFragment deleteFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initFragments();
        showContent();
    }

    private void initFragments() {
        editFragment = new OfflineEditFragment();
        deleteFragment = new OfflineDeleteFragment();
    }

    private void showContent() {
        if (editFragment.isAdded() && editFragment.isVisible())
            return;
        if (deleteFragment.isAdded() && deleteFragment.isVisible())
            getSupportFragmentManager().beginTransaction().replace(R.id.off_down_fl, editFragment).commit();
        else
            getSupportFragmentManager().beginTransaction().add(R.id.off_down_fl, editFragment).commit();
    }


    @Override
    public void doneClick() {
        getSupportFragmentManager().beginTransaction().replace(R.id.off_down_fl, editFragment).commit();
    }

    @Override
    public void editClick() {
        getSupportFragmentManager().beginTransaction().replace(R.id.off_down_fl, deleteFragment).commit();
    }
}
